This quick start guide outlines the steps for integrating Rules Manager with the FlexGrid control and applying conditional formatting to the grid data.
Users can achieve the desired output either through the design view or code view.
Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
C# |
Copy Code
|
---|---|
<i:Interaction.Behaviors> <c1:ConditionalFormattingBehavior/> </i:Interaction.Behaviors> |
XAML |
Copy Code
|
---|---|
<i:Interaction.Behaviors>
<c1:ConditionalFormattingBehavior Engine="{Binding ElementName=rulesManager, Path=Engine}"/>
</i:Interaction.Behaviors>
|
XAML |
Copy Code
|
---|---|
<c1:C1Expander Header="RulesManager" ExpandDirection="Left" ExpandIconAlignment="Left" HorizontalContentAlignment="Right" BorderThickness="0" Grid.Column="1"> <c1:C1RulesManager x:Name="rulesManager" Width="400" RulesVisibility="All"> <c1:C1RulesManager.Engine> </c1:C1RulesManager.Engine> </c1:C1RulesManager> </c1:C1Expander> |
XAML |
Copy Code
|
---|---|
<c1:C1Expander Header="RulesManager" ExpandDirection="Left" ExpandIconAlignment="Left" HorizontalContentAlignment="Right" BorderThickness="0" Grid.Column="1"> <c1:C1RulesManager x:Name="rulesManager" Width="400" RulesVisibility="All"> <c1:C1RulesManager.Engine> <c1:C1RulesEngine> </c1:C1RulesEngine> </c1:C1RulesManager.Engine> </c1:C1RulesManager> </c1:C1Expander> |
XAML |
Copy Code
|
---|---|
<c1:C1RulesManager.Engine> <c1:C1RulesEngine> <c1:RulesEngineCustomRule Func="GetFirstNameStyle" Ranges="[FirstName]"/> <c1:RulesEngineSegmentsRule/> <c1:RulesEngineExpressionRule Ranges="[OrderCount]" Expression="[OrderCount] < 50"> <c1:RulesEngineStyle Background="#FFFDE7E9"/> </c1:RulesEngineExpressionRule> <c1:RulesEngineExpressionRule Ranges="[OrderCount]" Expression="[OrderCount] >= 50"> <c1:RulesEngineStyle Background="#FFDFF6DD"/> </c1:RulesEngineExpressionRule> <c1:RulesEngineExpressionRule Ranges="[OrderTotal]" Expression="[OrderTotal] < 5000"> <c1:RulesEngineStyle Foreground="#FFC42B1C"/> </c1:RulesEngineExpressionRule> <c1:RulesEngineExpressionRule Ranges="[OrderTotal]" Expression="[OrderTotal] >= 5000"> <c1:RulesEngineStyle Foreground="#FF0F7B0F"/> </c1:RulesEngineExpressionRule> </c1:C1RulesEngine> </c1:C1RulesManager.Engine> |
In the example above, the C1Expander containing C1RulesManager applies conditional formatting to the FlexGrid. It uses C1RulesEnginge to style the grid cells based on the conditional formatting that is: rows with OrderCount less than 50 get a light red backcolor while those that are more or equal to 50 get light green color. For OrderTotal values that are less than 5000 gets a dark red forecolor while those that are greater than or equal to 5000 gets dark green color. Additionally, a Custom Rule is defined to style the FirstName column using a user-defined function. This setup helps visually highlight important data patterns for easier analysis.